FROM serversideup/php:8.2-fpm-nginx-v2.2.1

# Add /config to allowed directory tree
ENV PHP_OPEN_BASEDIR=$WEBUSER_HOME:/config/:/dev/stdout:/tmp

# Enable mixed ssl mode so port 80 or 443 can be used
ENV SSL_MODE="mixed"

# Install addition packages and cron file
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        cron \
        htop \
        php8.2-pgsql \
    && echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
    \
# Install Speedtest cli
    && curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash \
    && apt-get install -y --no-install-recommends speedtest \
    \
# Clean up package lists
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Copy package configs
COPY --chmod=755 docker/deploy/etc /etc

# Copy app
COPY --chown=webuser:webgroup . $WEBUSER_HOME

WORKDIR $WEBUSER_HOME

# Install app dependencies
RUN composer install \
    --no-interaction \
    --prefer-dist \
    --optimize-autoloader \
    --no-dev \
    --no-cache

VOLUME /config
